package org.yaglyf;

import com.alibaba.fastjson.JSON;
import org.yaglyf.api.entity.UserInfo;
import org.yaglyf.service.UserInfoServiceImpl;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Application {

	public static void main(String[] args) throws Exception {

        UserInfoServiceImpl service = new UserInfoServiceImpl();

        ServerSocket server = new ServerSocket(9090);
        while (true){
            try ( Socket accept = server.accept()){
                ObjectInputStream stream = new ObjectInputStream(accept.getInputStream());
                Object o = stream.readObject();
                System.out.println(o);

                UserInfo info = service.testINFO();
                String json = JSON.toJSONString(info);

                ObjectOutputStream objectOutputStream = new ObjectOutputStream(accept.getOutputStream());
                objectOutputStream.writeObject(json);
            }
        }
    }

}
